/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.acmwustl.bubble.controllers;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.swing.JLabel;
import javax.swing.SwingWorker;

/**
 *
 * @author officer
 */
public abstract class FormatterThread extends SwingWorker {

    SimpleDateFormat formatter;
    boolean running = true;
    JLabel dateLabel;

    public FormatterThread(JLabel l) {
        this.dateLabel = l;
    }

    public void shutdown() {
        running = false;
    }

    @Override
    protected Object doInBackground() throws Exception {
        while(running) {
            dateLabel.setText(formatter.format(Calendar.getInstance().getTime()));
            Thread.sleep(500);
        }
        return null;
    }
}